// pages/determining_curriculum_planning/determining_curriculum_planning.js
var App = getApp();
Page({
    /**
     * 页面的初始数据
     */
    data: {
        list:'',
        plan_list: [],//动作规划数组
        b_id: '',
        exercise_intensity:'',
        img:[],
        start: '',
        end: '',
        membership_id: '', 
        startDate: '',
        endDate: '',
        see_details:'',//代表是私教课程的详情列表跳转的
        member_id:"",//会员id
        item_id:'',
    },

    /**
     * 生命周期函数--监听页面加载
     */
    onLoad: function (options) {
        var This = this;
        This.setData({
            b_id: options.b_id,
            start: options.start,
            end: options.end,
            membership_id: options.membership_id, 
            startDate: options.startDate,
            endDate: options.endDate,
            see_details: options.see_details,
            member_id: options.member_id,
            item_id: options.item_id
        })
        This.loading();
    },
    //图片点击放大
    img_wx(e) {
        var This = this;
        wx.previewImage({
            current: e.currentTarget.dataset.img, // 当前显示图片的http链接
            urls: This.data.img // 需要预览的图片http链接列表
        })
    },
    //获取数据
    loading:function(){
        var This = this;
        App._get('coach/Coursearrange/coursePlanningList', {
            openid: wx.getStorageSync('openid'),
            store_id: wx.getStorageSync('store_id'),
            phone: wx.getStorageSync('phone'),
            // openid: 1,
            // store_id: 53,
            // phone: 15612340001,
            b_id: This.data.b_id
        }, function (res) {
            if (res.status == 1) {
                This.setData({
                    list: res.data,
                    plan_list: res.data.action_data,
                    exercise_intensity: res.data.exercise_intensity,
                    
                })
                var imgsplit = res.data.img.split(',');
                This.setData({
                    img: imgsplit
                })
                console.log(This.data.plan_list)
                if(This.data.exercise_intensity == 1){
                    This.setData({
                        exercise_intensity:'适度'
                    })
                }else if(This.data.exercise_intensity == 2) {
                    This.setData({
                        exercise_intensity: '中度'
                    })
                } else if (This.data.exercise_intensity == 3) {
                    This.setData({
                        exercise_intensity: '强烈'
                    })
                }
            } else {
                wx.showToast({
                    title: res.error,
                    image: '../../image/icon_danger.png',
                    duration: 2000
                })
            }
        })
    },
    // 编辑跳转
    step:function(){
        var This = this;
        wx.navigateTo({
            url: '../summary_training/summary_training?b_id=' + This.data.b_id + '&start=' + This.data.start + '&end=' + This.data.end + '&membership_id=' + This.data.membership_id + '&startDate=' + This.data.startDate + '&endDate=' + This.data.endDate + '&see_details=' + This.data.see_details + "&member_id=" + This.data.member_id + '&item_id=' + This.data.item_id,
        })
    },
    /**
     * 生命周期函数--监听页面初次渲染完成
     */
    onReady: function () {

    },
    
    /**
     * 生命周期函数--监听页面显示
     */
    onShow: function () {

    },

    /**
     * 生命周期函数--监听页面隐藏
     */
    onHide: function () {

    },

    /**
     * 生命周期函数--监听页面卸载
     */
    onUnload: function () {

    },

    /**
     * 页面相关事件处理函数--监听用户下拉动作
     */
    onPullDownRefresh: function () {

    },

    /**
     * 页面上拉触底事件的处理函数
     */
    onReachBottom: function () {

    },

    /**
     * 用户点击右上角分享
     */
    onShareAppMessage: function () {

    }
})